package com.cube.reactive.guide.reactive;

import reactor.core.publisher.Flux;

import java.util.concurrent.TimeoutException;

/**
 * @author litb
 * @since 2024/6/13 19:09
 */
public class OnErrorReturn {

    public static void main(String[] args) {
        //Flux.just("timeout1", "unknown", "key2")
        //        .flatMap(k -> callExternalService(k)
        //                .onErrorResume(error -> {
        //                    if (error instanceof »TimeoutException)
        //                        return getFromCache(k);
        //                    else if (error instanceof UnknownKeyException)
        //                        return registerNewEntry(k, "DEFAULT");
        //                    else
        //                        return Flux.error(error);
        //                })
        //        );

        //Flux<String> flux =
        //        Flux.just("unknown")
        //                .flatMap(k -> callExternalService(k)
        //                        .doOnError(e -> {
        //                            failureStat.increment();
        //                            log("uh oh, falling back, service failed for key " + k);
        //                        })
        //
        //                );

    }
}
